package com.hudson.plugin.server.hibernateDB.domain.dao;

import com.hudson.plugin.server.hibernateDB.internal.domain.entity.HudsonsEntity;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Richard
 * Date: 5/29/11
 * Time: 10:40 PM
 * To change this template use File | Settings | File Templates.
 */
public interface HudsonsDAOInterface {
    // property constants
    String URL = "url";
    String DESCRIPTION = "description";
    String SLAVES = "slaves";

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    void save(HudsonsEntity transientInstance);

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    void delete(HudsonsEntity persistentInstance);

    List findByProperty(String propertyName, Object value);

    HudsonsEntity findById(Integer id);

    List findByUrl(Object url);

    List findByDescription(Object description);

    List findBySlaves(Object slaves);

    List findAll();

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    HudsonsEntity merge(HudsonsEntity detachedInstance);

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    void attachDirty(HudsonsEntity instance);

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    void attachClean(HudsonsEntity instance);

    List<Integer> findHudsonsEntity(String url);
}
